﻿namespace NTLib.Core.UTest.Tasks
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using NTLib.Core.Tasks;
    using System.Threading;

    [TestClass]
    public class TasksExtUTest
    {
        #region Methods

        [TestCategory("Core.Tasks")]
        [TestMethod]
        public void TaskCompletionSource_Cancel()
        {
            CancellationTokenSource source = new CancellationTokenSource();
            TaskCompletionSource<bool> test = new TaskCompletionSource<bool>().AttachCancelToken(source.Token);

            source.Cancel();

            Assert.IsTrue(test.Task.IsCanceled);
        }

        #endregion
    }
}
